package org.mbds.android.p2p.listeners;

import java.util.ArrayList;
import java.util.Hashtable;

import org.mbds.android.p2p.services.P2pService;

import android.annotation.SuppressLint;
import android.net.wifi.p2p.WifiP2pDevice;
import android.net.wifi.p2p.WifiP2pManager.DnsSdServiceResponseListener;
import android.widget.Toast;

public class P2pDnsResponseListener{
	
	DnsSdServiceResponseListener mListener;
	P2pService mService;
	ArrayList<WifiP2pDevice> mDnsDevices; // Devices we can communicate with.
	
	public P2pDnsResponseListener(P2pService service){
		mService = service;
		mDnsDevices = new ArrayList<WifiP2pDevice>();
		initializeDnsResponseListener();
	}
	
	public void initializeDnsResponseListener(){
		mListener = new DnsSdServiceResponseListener() {
			
			@SuppressLint("NewApi")
			@Override
			public void onDnsSdServiceAvailable(String instanceName,
					String registrationType, WifiP2pDevice srcDevice) {
					Toast.makeText(mService.getApplicationContext(), "DNS", Toast.LENGTH_SHORT).show();
					mDnsDevices.add(srcDevice);
			}
		};
	}
	
	public DnsSdServiceResponseListener getListener(){
		return mListener;
	}
	
	public ArrayList<WifiP2pDevice> getDnsDevices(){
		return mDnsDevices;
	}
}
